<link rel="stylesheet" href="__PUBLIC__/js/jquery-upload/css/jquery.fileupload.css" />
<link rel="stylesheet" href="__PUBLIC__/js/jquery-upload/css/jquery.fileupload-ui.css" />

<link href="__PUBLIC__/css/select2/select2-bootstrap.min.css" rel="stylesheet" />
<div class="modal-dialog" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title" id="exampleModalLabel">商品标签添加</h4>
        </div>
        <form style="margin:4%;" id="addNewsCateForm" data-toggle="validator" role="form">
            <div class="form-group">
                <label for="tag_name" class="control-label">标签名称:</label>
                <input type="text" class="form-control" name="tag_name" value="{$cateInfo.tag_name}" data-error="标签名称不能为空!" data-minlength="2" required>
                <div class="help-block with-errors"></div>
            </div>
            <input type="hidden" name="id" value="{$cateInfo.id}" />
        </form>
        <div class="modal-footer">
            <button type="button" data-dismiss="modal" class="btn btn-default">取消</button>
            <button type="button" id="userSave" class="btn btn-primary">保存</button>
        </div>
    </div>
</div>

<script>
    var ROOTPATH = "__ROOT__";
    $(function () {
        $("#addNewsCateForm").validator();
       
    })

    $("#userSave").click(function () {
        var validator = $("#addNewsCateForm").data("bs.validator");
        validator.validate();
        if(!validator.hasErrors()){
            $.ajax({
                url: "{:U('Admin/Goods/doAddGoodsTags')}",
                type: "post",
                dataType: "json",
                data: $("#addNewsCateForm").serialize(),
                success: function (data) {
                    //console.log(data);
                    if(data.status){
                        $("#commonModal").modal('toggle');
                        common.alert("提示", data.msg, function () {
                            common.reload();
                        });
                    }else{
                        common.alert("提示", data.msg)
                    }
                }
            })
        }
    });
</script>